/**
 * Created by bian on 2015/12/28.
 */
var express = require('express');
var app = express();
var path = require('path');
var bodyParser = require('body-parser');
var sequelize = require('./models/index');

var infos = sequelize.models.infos;
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);

app.get('/',function(req,res){
    res.render('index');
});

app.post('/data',function(req,res){
    try{
        var data = req.body;
        console.log(data);
        infos.create(data);
        res.send('1');
    }catch(err){
        console.log(err);
        res.send('0');
    }
});

app.listen(3000);